home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Apple Macintosh Developer Technical Support
- **
- ** File: TOvalObj.c
- ** Written by: Eric Soldan
- **
- ** Copyright © 1992-1993 Apple Computer, Inc.
- ** All rights reserved.
- */
-
- /* You may incorporate this sample code into your applications without
- ** restriction, though the sample code has been provided "AS IS" and the
- ** responsibility for its operation is 100% yours. However, what you are
- ** not permitted to do is to redistribute the source as "DSC Sample Code"
- ** after having made changes. If you're going to re-distribute the source,
- ** we require that you make it clear in the source that the code was
- ** descended from Apple Sample Code, but that you've made changes. */
-
- /* See the files "=How to write your app" and "=Using TreeObj.c" for information
- ** on this function. */
-
- /* This file implements the messages for the oval object. Many of the messages
- ** can be handled by the rect object, as they deal with a rect structure. Only
- ** a few of them are oval-specific. */
-
- /* It would seem that you would want a custom hit-test message handler here, but
- ** the rect object first checks to see if the hit is within the bounding box of
- ** the object, and if so, it then calls the object to return the region. This
- ** allows the rect object to generically handle hit-testing. */
-
-
-
- /*****************************************************************************/
-
-
-
- #include "App.h" /* Get the application includes/typedefs, etc. */
- #include "App.protos.h" /* Get the prototypes for the application. */
-
- #ifndef __OSEVENTS__
- #include <OSEvents.h>
- #endif
-
- #ifndef __OSUTILS__
- #include <OSUtils.h>
- #endif
-
- #ifndef __QUICKDRAW__
- #include <Quickdraw.h>
- #endif
-
- #ifndef __STRING__
- #include <String.h>
- #endif
-
- #ifndef __TREEOBJ2__
- #include "TreeObj2.h"
- #endif
-
- #ifndef __UTILITIES__
- #include "Utilities.h"
- #endif
-
-
-
- #pragma segment DrawObjects
- long TOvalObj(TreeObjHndl hndl, short message, long data)
- {
- Rect rct;
- RgnHandle rgn, accumRgn;
- short h, w;
- RGBColor rgb, rgb2;
- #if VH_VERSION
- char *cptr;
- #endif
-
- switch (message) {
- case INITMESSAGE:
- case FREEMESSAGE:
- case COPYMESSAGE:
- case UNDOMESSAGE:
- case CONVERTMESSAGE:
- case FREADMESSAGE:
- case FWRITEMESSAGE:
- case HREADMESSAGE:
- case HWRITEMESSAGE:
- case HITTESTMESSAGE:
- case GETOBJRECTMESSAGE:
- case SETOBJRECTMESSAGE:
- case SECTOBJRECTMESSAGE:
- case GETBBOXMESSAGE:
- case CLICKMESSAGE:
- case KEYMESSAGE:
- case SETSELECTMESSAGE:
- case GETSELECTMESSAGE:
- case SIZEMESSAGE:
- case COMPAREMESSAGE:
- return(TRectObj(hndl, message, data));
- break;
-
- case GETRGNMESSAGE:
- rgn = NewRgn();
- accumRgn = (RgnHandle)data;
- if (accumRgn)
- if (GetHandleSize((Handle)accumRgn) > 10000)
- return((long)rgn);
- OpenRgn();
- rct = mDerefOval(hndl)->oval;
- FrameOval(&rct);
- CloseRgn(rgn);
- if (accumRgn)
- UnionRgn(rgn, accumRgn, accumRgn);
- return((long)rgn);
- break;
-
- case DRAWMESSAGE:
- rct = mDerefOval(hndl)->oval;
- h = mDerefCommon(hndl)->penHeight;
- w = mDerefCommon(hndl)->penWidth;
- PenSize(w, h);
- switch (data) {
- case DRAWOBJ:
- if (gQDVersion)
- GetForeColor(&rgb);
- ForeColor(whiteColor);
- if (gQDVersion) {
- rgb2 = mDerefOval(hndl)->contentColor;
- RGBForeColor(&rgb2);
- }
- PaintOval(&rct);
- ForeColor(blackColor);
- if (gQDVersion) {
- rgb2 = mDerefOval(hndl)->borderColor;
- RGBForeColor(&rgb2);
- }
- FrameOval(&rct);
- if (gQDVersion)
- RGBForeColor(&rgb);
- break;
- case ERASEOBJ:
- EraseOval(&rct);
- break;
- case DRAWSELECT:
- TRectObj(hndl, message, data);
- break;
- case DRAWGHOST:
- PenMode(patXor);
- FrameOval(&rct);
- break;
- case DRAWMASK:
- FillOval(&rct, (ConstPatternParam)&qd.black);
- break;
- }
- PenNormal();
- break;
-
- case PRINTMESSAGE:
- TOvalObj(hndl, DRAWMESSAGE, DRAWOBJ);
- break;
-
- #if VH_VERSION
- case VHMESSAGE:
- cptr = ((VHFormatDataPtr)data)->data;
- ccatchr(cptr, 13, 2);
- ccat (cptr, "$10: TOvalObj:");
- ccatchr(cptr, 13, 1);
- ccat (cptr, " $00: selected = ");
- ccatdec(cptr, mDerefOval(hndl)->selected);
- ccatchr(cptr, 13, 1);
- rct = mDerefOval(hndl)->oval;
- ccat (cptr, " $02: oval = ($");
- ccatpadhex(cptr, 0, 4, 4, rct.top);
- ccat (cptr, ",$");
- ccatpadhex(cptr, 0, 4, 4, rct.left);
- ccat (cptr, ",$");
- ccatpadhex(cptr, 0, 4, 4, rct.bottom);
- ccat (cptr, ",$");
- ccatpadhex(cptr, 0, 4, 4, rct.right);
- ccat (cptr, ")");
- ccatchr (cptr, 13, 1);
- ccat (cptr, " $0A: penHeight = ");
- ccatdec (cptr, mDerefOval(hndl)->penHeight);
- ccatchr (cptr, 13, 1);
- ccat (cptr, " $0C: penWidth = ");
- ccatdec (cptr, mDerefOval(hndl)->penWidth);
- ccatchr (cptr, 13, 1);
- ccat (cptr, " $0E: borderColor = ($");
- ccatpadhex(cptr, 0, 4, 4, mDerefOval(hndl)->borderColor.red);
- ccat (cptr, ",$");
- ccatpadhex(cptr, 0, 4, 4, mDerefOval(hndl)->borderColor.green);
- ccat (cptr, ",$");
- ccatpadhex(cptr, 0, 4, 4, mDerefOval(hndl)->borderColor.blue);
- ccat (cptr, ")");
- ccatchr (cptr, 13, 1);
- ccat (cptr, " $1$: content = ($");
- ccatdec (cptr, mDerefOval(hndl)->content);
- ccatchr (cptr, 13, 1);
- ccat (cptr, " $16: contentColor = ($");
- ccatpadhex(cptr, 0, 4, 4, mDerefOval(hndl)->contentColor.red);
- ccat (cptr, ",$");
- ccatpadhex(cptr, 0, 4, 4, mDerefOval(hndl)->contentColor.green);
- ccat (cptr, ",$");
- ccatpadhex(cptr, 0, 4, 4, mDerefOval(hndl)->contentColor.blue);
- ccat (cptr, ")");
- return(true);
- break;
- #endif
-
- default:
- break;
- }
-
- return(noErr);
- }
-
-
-
-